//
//  ArtCircleViewController.m
//  ArtCircle
//
//  Created by sunbin on 2017/5/20.
//  Copyright © 2017年 HuaYue. All rights reserved.
//

#import "ArtCircleViewController.h"
#import "ViewController.h"

#import "AboutMe.h"
#import "Login.h"

#import "QuickLogin.h"

@interface ArtCircleViewController ()<LeftMenuViewDelegate>

@property (nonatomic, strong) MLMSegmentHead *segHead;     // 头部
@property (nonatomic, strong) MLMSegmentScroll *segScroll; // 滑动SegmentScroll

@end

@implementation ArtCircleViewController
{
    NSArray *list;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.tabBarController.tabBar.hidden = NO;
    
//    NSLog(@"%@" ,self.navigationController.viewControllers);
//    
//    
//    [self pushAndPop:[[QuickLogin alloc] init] range:NSMakeRange(1, 2)];
//    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];


    //[self leftView];

    [self segmentStyle4];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:Icon(@"按下") style:UIBarButtonItemStylePlain target:self action:@selector(leftAction)];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:Icon(@"按下添加") style:UIBarButtonItemStylePlain target:self action:@selector(leftAction)];


}

- (void)leftAction {

#pragma maek -判断是否登录 如登录显示左侧抽屉 未登录显示登录页面
    //[self.menu show];



    
    
    
    
    [self.navigationController pushViewController:[[Login alloc] init] animated:NO];
}




- (void)leftView{
    LeftMenuView *leftMenuView = [[LeftMenuView alloc] initWithFrame:CGRectMake(0, 0, 3*SCREEN_WIDTH/5+SCREEN_WIDTH/10, SCREEN_HEIGHT)];
    
    
    leftMenuView.delegate = self;
    
    
    self.menu = [[MenuView alloc] initWithDependencyView:self.view MenuView:leftMenuView isShowCoverView:YES];
    
}

#pragma make -LeftMenuViewDelegate 跳转
-(void)leftMenuViewClick:(NSInteger)tag {
    

    [self.menu hidenWithAnimation];

    AboutMe *aboutMe = [[AboutMe alloc] init];
    
    [self.navigationController pushViewController:aboutMe animated:NO];

    
}




#pragma mark - 居中默认
- (void)segmentStyle4 {
    list = @[@"推荐",
             @"视频"
             ];
    
    _segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, 40) titles:list headStyle:_style layoutStyle:_layout];
    _segHead.fontScale = 1.1;
    
    _segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_segHead.frame), SCREEN_WIDTH, SCREEN_HEIGHT-CGRectGetMaxY(_segHead.frame)) vcOrViews:[self vcArr:list.count]];
    _segScroll.loadAll = YES;
    
    [MLMSegmentManager associateHead:_segHead withScroll:_segScroll completion:^{
        [self.view addSubview:_segHead];
        [self.view addSubview:_segScroll];
    }];
}
- (NSArray *)vcArr:(NSInteger)count {
    NSMutableArray *arr = [NSMutableArray array];
    for (NSInteger i = 0; i < count; i ++) {
        ViewController *vc = [[ViewController alloc] initWithStyle:UITableViewStylePlain];
        
        [arr addObject:vc];
    }
    return arr;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
